home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / inn1.000 / inn1.4sec-linux-src.tar / inn / lib / strspn.c < prev    next >
C/C++ Source or Header  |  1991-11-27  |  2KB  |  59 lines

  1. /*  $Revision: 1.2 $
  2. **
  3. **  This file has been modified to get it to compile more easily
  4. **  on pre-4.4BSD systems.  Rich $alz, June 1991.
  5. */
  6. #define const /* NULL */
  7. #define size_t int
  8. #define NULL 0
  9.  
  10. /*
  11.  * Copyright (c) 1989 The Regents of the University of California.
  12.  * All rights reserved.
  13.  *
  14.  * Redistribution and use in source and binary forms are permitted
  15.  * provided that: (1) source distributions retain this entire copyright
  16.  * notice and comment, and (2) distributions including binaries display
  17.  * the following acknowledgement:  ``This product includes software
  18.  * developed by the University of California, Berkeley and its contributors''
  19.  * in the documentation or other materials provided with the distribution
  20.  * and in all advertising materials mentioning features or use of this
  21.  * software. Neither the name of the University nor the names of its
  22.  * contributors may be used to endorse or promote products derived
  23.  * from this software without specific prior written permission.
  24.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  25.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  26.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27.  */
  28.  
  29. #if 0
  30. #if defined(LIBC_SCCS) && !defined(lint)
  31. static char sccsid[] = "@(#)strspn.c    5.7 (Berkeley) 6/1/90";
  32. #endif /* LIBC_SCCS and not lint */
  33.  
  34. #include <sys/stdc.h>
  35. #include <string.h>
  36. #endif
  37.  
  38. /*
  39.  * Span the string s2 (skip characters that are in s2).
  40.  */
  41. size_t
  42. strspn(s1, s2)
  43.     const char *s1;
  44.     register const char *s2;
  45. {
  46.     register const char *p = s1, *spanp;
  47.     register char c, sc;
  48.  
  49.     /*
  50.      * Skip any characters in s2, excluding the terminating \0.
  51.      */
  52. cont:
  53.     c = *p++;
  54.     for (spanp = s2; (sc = *spanp++) != 0;)
  55.         if (sc == c)
  56.             goto cont;
  57.     return (p - 1 - s1);
  58. }
  59.